package com.sk.controller;

import com.sk.utils.FdfsUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

@Controller

public class UploadTest {

    @GetMapping("/upload")
    public String toUpload(){
        return "upload";
    }

    @PostMapping("/upload")
    @ResponseBody
    public String file(MultipartFile file){
        FdfsUtils fdfsUtils = new FdfsUtils();
        if (file != null) {
            String path = fdfsUtils.upload(file);
            return "http://hanbing777.top:8889/"+path;
        }
        return null;
    }

}
